package structural_pattern.facade_pattern;

/**
 * 加密外观类
 */
public class EncryptFacade {
   //维持对子系统对象的引用。
    private FileReader reader;
    private CipherMachine cipherMachine;
    private FileWriter fileWriter;

    public EncryptFacade(){
        reader = new FileReader();
        cipherMachine = new CipherMachine();
        fileWriter = new FileWriter();
    }
    //调用其他业务对象的业务方法。
    public void fileEncrypt(String fileNameSrc,String fileNameDes){
        String plainSrc = reader.read(fileNameSrc);
        String encryptStr = cipherMachine.encrypt(plainSrc);
        fileWriter.write(encryptStr,fileNameDes);
    }
}
